﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	评论处理页面
'	2012.4.5

'特别说明: id=0 表示群聊功能,其他为文章ID

Sub main
	'评论配置
	If Not ifNum(numDiscuss) Then numDiscuss="0"'文章评论最少字数

	Dim o,rs,id,body_,pl,p,pl_len,user,err_str
	hu.title = "发表评论"
	body_ = ""
	id=getN("id",1)
	pl=getD("pl","")
	p=getN("p",1)
	pl_len=len(pl)
	err_str=""
	user=user_array(0)&""'取当前用户ID
	If user="0" Then
		user=User_Ip'游客记录IP
	End If
	
	If wapDiscuss = "1" And user="0" Then err_str="登录评论/群聊！"
	
	if pl_len=0 And err_str="" then err_str="评论内容不能为空！"
	if left(pl, 1)="$" And pl_len<10 And err_str="" then err_str="评论方式有误！"
	if pl_len<numDiscuss*1 And err_str="" then err_str="评论内容最少"&numDiscuss&"字！"
	if pl_len>100 And err_str="" Then err_str="评论内容最多100字！"

	if id<>0 And err_str="" then
		Set rs=hu.conn("select top 1 id from 74hu_article where id="&id)
		If rs.eof Then
			err_str="评论文章不存在！"
		Else
			Set rs=hu.conn("select top 1 id from 74hu_pl where pl='"&pl&"' and smsid="&id)
			if not rs.eof then err_str="评论内容已存在！请不要重复提交"
		End If
	end if

	if id=0 And err_str="" then
		Set rs=hu.conn("select top 1 id from 74hu_pl where pl='"&pl&"' and ip='"&user&"'")
		if not rs.eof then err_str="群聊内容已存在！请不要重复提交"
	end if

	If err_str="" Then
		Dim timeInterval'防止刷帖,10秒回复一条
		Set rs=hu.conn("select top 1 pltime from 74hu_pl where ip='"&user&"' order by id desc")
		If Not rs.eof Then
			timeInterval = DateDiff("s", rs("pltime"), time_now)
			If timeInterval <10 Then rupt "错误", "为提高评论质量,两次评论间隔必须大于10秒!"
			If timeInterval >30 And user<>"" And IsNumeric(user) Then Call setUserAmount(user, amtComment)'会员加金币积分经验
		End If
		hu.conn("insert into 74hu_pl (pl,ip,smsid,pltime)values('"&pl&"','"&user&"',"&id&",'"&time_now&"')")
		if id<>0 then hu.conn("update 74hu_article Set smspin = smspin+1 where ID="&id)
		hu.AutoRedirect = http_path&"discuss.asp?id="&id&"&amp;p="&p&"&amp;"&sid_str
		body_ = "评论发表成功！"
	Else
		body_ = err_str
	End If
	body_ = body_ & "<br/>" & hu.url("discuss.asp?id="&id&"&amp;p="&p,"查看评论")
	if id<>0 then body_ = body_ & "<br/>"& hu.url("article.asp?id="&id&"&amp;p="&p, "返回原文") & "<br/>"
	hu.body = body_
End Sub

%>